package org.bakerstreet.components.render;

import org.bakerstreet.components.Component;

public class CheckBoxRender extends ComponentRender {

	@Override
	public void render(Component comp, StringBuffer sb) {
		super.render(comp, sb);
		String containerId = "$"+comp.getRow()+"$"+comp.getColumn();
		sb.append("comp"+comp.getId()+" = new CheckBox(\""+comp.getId()+"\",\""+containerId+"\");");
		sb.append("comp"+comp.getId()+".render();");
		sb.append("comp"+comp.getId()).append(".setValue(\"").append(comp.getValue()).append("\");");
	}

	@Override
	public void update(Component comp, StringBuffer sb) {
		String jsComponent = "comp"+comp.getId(); 
		sb.append(jsComponent).append(".setValue(").append(comp.getValue()).append("); ");
		sb.append(jsComponent).append(".setEnabled(").append(comp.isEnabled()).append("); ");
	}

	
}
